import { defineStore } from "pinia";
import { getHeadImgCategory, getHeadImgs } from '@/api/headImg/headImg';

const headImg = defineStore("headImg", {
  state: () => ({
    headImgCategory:[],
    headImgs:[]
  }),
  actions: {
    async getHeadImgCategory(categoryName) {
      const res = await getHeadImgCategory(categoryName)
      this.headImgCategory = res.data.list[0].children
      this.getHeadImgs(this.headImgCategory[0].id)
      return [this.headImgCategory[0]]
    //   console.log('获取到的头像信息',this.headImgCategory)

    },
    async getHeadImgs(categoryId) {
      const res = await getHeadImgs(categoryId)
      this.headImgs = res.data
      console.log('获取到的头像信息',this.headImgs)

    },
    
  }
})

export default headImg

